#include "Player.h"
#include "Card.h"
#include <iostream>
#include <string.h>
#include<QtCore>
using namespace std;

//Class created by CP botha
Player::Player(Hand h, int i,game* g,Server *s)
{
    server=s;
    localHand=h;
    id=i;
    gui=g;
    //localHand.updateOwner(i);
    dummyFlag = false;
    declarer = false;

}

Card Player::getMove(bool)
{
    Card card('c',0,0,"string");
    return card;
}
Hand Player::getValidMoves()
{

}

void Player::sendHand()
{

}

QStringList Player::getBid()
{
    QStringList null;
    return null;
}

void Player::startDummy()
{

}

void Player::sendScoreUpdate(string)
{

}
void Player::sendGameWinner(QString)
{

}

void Player::sendRubberWinner(QString)
{

}

void  Player::sendGameStatus(QStringList)
{

}

string Player::getUsername()
{
    return username;
}

bool Player::setUsername(string usr)
{
    username=usr;
    return true;
}

bool Player::setLocalHand(Hand h)
{
    dummyFlag = false;
    declarer = false;
    h.sortHand();
    localHand=h;
    return true;
}

Player* Player::getPartner()
{
    return partner;
}

void Player::sendBid(QStringList, int)
{

}

void Player::sendMove(Card, QString)
{

}

void Player::print()
{
    qDebug()<<"===================================\n";
      qDebug()<<"player id = "<<id<<"\n";
      qDebug()<<"player username = "<<QString::fromStdString(username)<<"\n";
      qDebug()<<"player hand \n";
    localHand.print();
      qDebug()<<"Declarer = "<<declarer<<"\n";
      qDebug()<<"Dummy = "<<dummyFlag<<"\n";
    //cout<<"Highest bid "<<getHighestBid()<<"\n";
      qDebug()<<"===================================\n";
}

void Player::moveInvalid()
{

}

void Player::bidInvalid()
{

}

void Player::startDealing()
{

}

void Player::startRedealing()
{

}

void Player::startBidding()
{

}

void Player::startPlay()
{

}

void Player::RubberDone()
{

}

void Player::sendTrickWinner(QString, QString)
{

}

void Player::sendContract(QStringList contract)
{
    qDebug()<<"Contract";
    qDebug()<<contract.at(0);
    qDebug()<<contract.at(1);
    qDebug()<<contract.at(2);
}
void Player::updateTrump(QChar suit)
{
    for(int i=0;i<localHand.getHandSize();i++)
    {
        if(localHand.getCard(i)->suit==suit)
            localHand.getCard(i)->trump=true;

    }
}
void Player::sendDummyId(string)
{

}

void Player::sendDummyCards(Hand)
{

}

bool Player::hasCardsInSuit(char suit)
{
    if(localHand.numberOfSuit(suit)>0)
        return true;
    return false;
}

void Player::updateScore(QString, QString, QString, QString)
{

}
